function sendShout(data,callback,error){$j.ajax({type:"POST",url:"/ajax/shouts/post",dataType:"json",data:data,success:function(json){if(typeof (callback)=="function"){return callback(json)
}analyticsEvent("event16","shout")},error:function(xml){var json=eval("("+xml.responseText+")");if(typeof (error)=="function"){return error(json)
}else{alert((json.error)?json.error:json.message)}}});return false}function remShout(data,callback){$j.ajax({type:"POST",url:"/ajax/shouts/remove",dataType:"json",data:data,success:function(json){if(typeof (callback)=="function"){return callback(json)
}analyticsEvent("event12","remove shout")},error:function(xml){var json=eval("("+xml.responseText+")");
alert((json.error)?json.error:json.message)}})};var Sharebox=Class.create({tab:function(A){$j("#lightbox-blog-it-tab, #lightbox-email-it-tab, #lightbox-shout-it-tab").removeClass("active");
$j("#lightbox-"+A+"-tab").addClass("active");$j("#lightbox-blog-it, #lightbox-email-it, #lightbox-shout-it, #lightbox-share-notice").hide();
$j("#lightbox-"+A).show()},reCaptcha:function(A){var B=$j(A+"-captcha");if(B.length==0){return }B.html('<img src="/img/c-spinner.gif" alt=""/> Loading captcha...');
$j(A+"-post").attr("disabled","disabled");$j.ajax({url:"/ajax/captcha/lightbox.html",async:true,type:"POST",dataType:"html",data:{token:tokens.captcha.lightbox},success:function(C){B.html(C);
$j(A+"-post").removeAttr("disabled")},error:function(C){B.html('<li class="warning">We couldn\'t load a new captcha for you :( &nbsp;Please reload the page.</li>');
$j(".warning").show()}})}},true);Sharebox.namespace({shouts:{select:function(B){var A=$j("#friend"+B);
if(A.hasClass("selected")){A.removeClass("selected")}else{A.addClass("selected")}},toggleAll:function(){var B="addClass",A=$j("#lightbox-shout-friends a");
if(A.length==$j(".selected",A).length){B="removeClass"}A[B]("selected");$j("#lightbox-shout-filter").focus()
},send:function(D){var E=[],B=$j("#lightbox-shout-friends a.selected");if(B.length<1){alert("Please select one or more friends to send this shout to");
return false}$j("#sendShout").val("Shouting!").attr("disabled","disabled");var A="",C="";if($j("#lightbox-shout-captcha-text").length){A=$j("#lightbox-shout-captcha-text").val();
C=$j("#md5").val()}B.each(function(){E.push($j(this).text()!=""?$j(this).text():",")});sendShout({token:tokens.shouts.post,to:E.join(","),shout:$j("#lightbox-shout-text").val(),activity:9,activityid:D,captcha:A,md5:C},function(F){$j("#lightbox-share-notice").html('<div class="confirm"><div><h3>Success!</h3>Your shout was successfully sent</div></div>').show().fadeTo(3000,1,function(){$j("#lightbox-share-notice").fadeOut(3000)
});$j("#lightbox-shout-filter").val("");$j("#lightbox-shout-text").val("");$j("#sendShout").removeAttr("disabled").val("Shout It!");
if(ups){ups.prefix="";ups.search()}$j("#lightbox-shout-friends a").removeClass("selected");$j("#lightbox-shout-filter").focus()
},function(F){errorMsg=F.error?F.error:F.message;$j("#lightbox-share-notice").html('<div class="warning"><div><h3>ERROR!</h3>'+errorMsg+"</div></div>").show().fadeTo(3000,1,function(){$j("#lightbox-share-notice").fadeOut(3000)
})})}},email:{add:function(){var C=$j(".lightbox-email-wrapper");var B=C.length+1;var A=$j(".lightbox-email-wrapper:last");
if(B<7){A.after('<div class="lightbox-email-wrapper" style="margin-right: 200px; clear: left;"><input style="width: 200px; margin-bottom: 3px;" class="lightbox-email" type="text" name="email'+B+'" id="email'+B+'" value="" /></div>')
}if(B==6){$j(".lightbox-add").hide()}},viewMessage:function(){$j("#lightbox-message-text-toggle").hide();
$j("#lightbox-message-text").show()},updateAppLink:function(){var B="";$j(".lightbox-email").each(function(C){B+=C.val()!=""?C.val()+",":""
});B=B.replace(/,$/,"");var A=$j("#lightbox-email-app");A.attr("href",A.attr("href").replace(/mailto:[^\?]*\?/,"mailto:"+B+"?"))
}}});$j(document).bind("shareBoxLoaded",function(){$j("#lightbox-shout-it-tab a").click(function(e){Sharebox.tab("shout-it");
e.preventDefault()});$j("#lightbox-email-it-tab a").click(function(e){Sharebox.tab("email-it");e.preventDefault()
});$j("#lightbox-blog-it-tab a").click(function(e){Sharebox.tab("blog-it");e.preventDefault()});$j("#lightbox-email-post").click(function(e){var el=$j(e.target);
var form=el.parents("form").get(0);el.val("Sending...").attr("disabled","disabled");var data={token:tokens.share.email};
$j(":text, textarea, #lightbox-email-id, #md5",form).not("#message-text2").each(function(){var _this=$j(this);
data[_this.attr("id")]=_this.val()});$j.ajax({url:"/ajax/share/email",data:data,type:"POST",dataType:"json",success:function(json){$j("#lightbox-email-captcha").remove();
el.val("Send Message").removeAttr("disabled");$j("#lightbox-share-notice").html('<div class="confirm"><div><h3>Success!</h3>Your email was successfully sent</div></div>').show().fadeTo(3000,1,function(){$j("#lightbox-share-notice").fadeOut(3000)
})},error:function(xml){var json=eval("("+xml.responseText+")");Sharebox.reCaptcha("#lightbox-email");
el.val("Send Message").removeAttr("disabled");errorMsg=json.error?json.error:json.message;$j("#lightbox-share-notice").html('<div class="warning"><div><h3>ERROR!</h3>'+errorMsg+"</div></div>").show().fadeTo(3000,1,function(){$j("#lightbox-share-notice").fadeOut(3000)
})}})});$j("#lightbox-blog-post").click(function(e){var el=$j(e.target);var form=el.parents("form").get(0);
el.val("Posting...").attr("disabled","disabled");var data={token:tokens.share.blog};$j(":text, textarea, #lightbox-blog-id",form).each(function(){var _this=$j(this);
data[_this.attr("name")]=_this.val()});$j.ajax({url:"/ajax/share/blog",data:data,type:"POST",dataType:"json",success:function(json){el.val("Blog it!").removeAttr("disabled");
$j("#lightbox-share-notice").html('<div class="confirm"><div><h3>Success!</h3>Your blog was successfully posted</div></div>').show().fadeTo(3000,1,function(){$j("#lightbox-share-notice").fadeOut(3000)
})},error:function(xml){el.val("Blog it!").removeAttr("disabled");var json=eval("("+xml.responseText+")");
errorMsg=json.error?json.error:json.message;$j("#lightbox-share-notice").html('<div class="warning"><div><h3>ERROR!</h3>'+errorMsg+"</div></div>").show().fadeTo(3000,1,function(){$j("#lightbox-share-notice").fadeOut(3000)
})}})})});